var t, e = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        showBox: !1,
        form: {
            tel: "",
            name: "",
            sms_code: ""
        },
        mobile: "",
        count: "",
        timer: null,
        showWarning: !1,
        href: ""
    },
    onLoad: function(e) {
        t = this;
    },
    onShow: function() {},
    sureAdd: function() {
        if (this.data.form.sms_code) {
            var e = a.getNetAddresss("plugin.yun-sign.frontend.h5.worker.add-worker");
            a._getNetWork({
                url: e,
                data: t.data.form,
                success: function(e) {
                    if (1 === e.data.result) {
                        var a = e.data;
                        t.setData({
                            tel: "",
                            name: "",
                            sms_code: ""
                        }), wx.showModal({
                            content: a.msg,
                            showCancel: !1,
                            success: function() {
                                wx.navigateTo({
                                    url: "/packageH/signPage/staffManagement/staffManagement"
                                });
                            }
                        });
                    } else wx.showModal({
                        content: e.data.msg,
                        showCancel: !1
                    });
                },
                fail: function(t) {
                    console.log(t, "-------------失败-------------");
                }
            });
        } else a.tips("请输入验证码");
    },
    sendCode: function() {
        this.data.form.tel ? this.data.form.name ? this.getAuthCode() : a.tips("请先输入员工姓名") : a.tips("请先输入员工手机号");
    },
    getAuthCode: function() {
        var e = a.getNetAddresss("plugin.yun-sign.frontend.h5.worker.add-worker-sms");
        wx.showLoading({
            title: "loading"
        }), a._postNetWork({
            url: e,
            data: {
                tel: this.data.form.tel,
                name: this.data.form.name
            },
            success: function(e) {
                if (wx.hideLoading(), console.log(e), 1 === e.data.result) if (1 == e.data.data.auth_status) {
                    t.timer || (t.countDown = 60, t.timer = setInterval(function() {
                        t.countDown > 0 && t.countDown <= 60 ? t.setData({
                            count: --t.countDown
                        }) : (clearInterval(t.timer), t.timer = null);
                    }, 1e3));
                } else t.setData({
                    showWarning: !0
                }); else wx.showModal({
                    content: e.data.msg,
                    showCancel: !1
                });
            },
            fail: function(t) {
                wx.hideLoading(), console.log(t, "---------失败---------");
            }
        });
    },
    handlerInput: function(t) {
        var a = t.target.dataset.type;
        this.setData(e({}, "".concat(a), t.detail));
    },
    handleShowBox: function() {
        this.setData({
            showBox: !this.data.showBox
        });
    },
    onHide: function() {}
});